package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Bank.DebugListener;
import com.acme.bankapp.domain.bank.Bank.EmailNotificationListener;
import com.acme.bankapp.domain.bank.Bank.PrintClientListener;

public class BankApplication {
	private static String feedPath;
	public static void main(String[] args) {
		ClientRegistrationListener[] listeners = clientRegistrationListenersCreator();

		Bank bank = new Bank(listeners);
		BankService bankService = new BankService(bank);
		
		for(int i = 0 ; i < args.length; i++){
			if ("-loadfeed".equals(args[i])){
				feedPath = args[++i];
			}
			if ("-loadbank".equals(args[i])){
				bankService.SAVE_BANK_PATH = args[++i];
			}
		}
		
		if (feedPath != null){
			bankService.loadFeedData( feedPath);
		}
		
	}

	private static ClientRegistrationListener[] clientRegistrationListenersCreator() {
		return new ClientRegistrationListener[] { new DebugListener(), new EmailNotificationListener(), new PrintClientListener() };
	}

}
